home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / srcuc.zip / BCHDRN.H < prev    next >
C/C++ Source or Header  |  1992-06-03  |  5KB  |  188 lines

  1. /* -*-C-*-
  2.  
  3. $Header: /scheme/src/microcode/RCS/bchdrn.h,v 1.4 1992/06/03 21:54:00 jinx Exp $
  4.  
  5. Copyright (c) 1991-1992 Massachusetts Institute of Technology
  6.  
  7. This material was developed by the Scheme project at the Massachusetts
  8. Institute of Technology, Department of Electrical Engineering and
  9. Computer Science.  Permission to copy this software, to redistribute
  10. it, and to use it for any purpose is granted, subject to the following
  11. restrictions and understandings.
  12.  
  13. 1. Any copy made of this software must include this copyright notice
  14. in full.
  15.  
  16. 2. Users of this software agree to make their best efforts (a) to
  17. return to the MIT Scheme project any improvements or extensions that
  18. they make, so that these may be included in future releases; and (b)
  19. to inform MIT of noteworthy uses of this software.
  20.  
  21. 3. All materials developed as a consequence of the use of this
  22. software shall duly acknowledge such use, in accordance with the usual
  23. standards of acknowledging credit in academic research.
  24.  
  25. 4. MIT has made no warrantee or representation that the operation of
  26. this software will be error-free, and MIT is under no obligation to
  27. provide any services, by way of maintenance, update, or otherwise.
  28.  
  29. 5. In conjunction with products arising from the use of this material,
  30. there shall be no use of the name of the Massachusetts Institute of
  31. Technology nor of any adaptation thereof in any advertising,
  32. promotional, or sales literature without prior written consent from
  33. MIT in each case. */
  34.  
  35. /* Header file for overlapped I/O in bchscheme. */
  36.  
  37. #ifndef _BCHDRN_H_INCLUDED
  38.  
  39. #define _BCHDRN_H_INCLUDED
  40.  
  41. #include "ansidecl.h"
  42. #include "oscond.h"
  43. #include <errno.h>
  44. #include <signal.h>
  45.  
  46. #if defined(_POSIX) || defined(_SUNOS4)
  47. #  include <unistd.h>
  48. #else
  49. #ifndef DOS386
  50.   extern int EXFUN (read, (int, PTR, unsigned int));
  51.   extern int EXFUN (write, (int, PTR, unsigned int));
  52. #endif
  53. #endif
  54.  
  55. #if defined(HAVE_POSIX_SIGNALS) && defined(HAVE_BSD_SIGNALS)
  56. #  define RE_INSTALL_HANDLER(signum,handler)    do { } while (0)
  57. #else
  58. #  define RE_INSTALL_HANDLER(signum,handler)    signal (signum, handler)
  59. #endif
  60.  
  61. /* #define AVOID_SYSV_SHARED_MEMORY */
  62.  
  63. #ifndef AVOID_SYSV_SHARED_MEMORY
  64. #  if defined(_SYSV4) || defined(_SUNOS4) || defined(_ULTRIX)
  65. #    define HAVE_SYSV_SHARED_MEMORY
  66. #  endif
  67. #endif
  68.  
  69. #if defined(_HPUX)
  70.  
  71. #  define HAVE_PREALLOC
  72.  
  73. #  include <magic.h>
  74. #  if defined(SHL_MAGIC)
  75. #    define hpux8 1
  76. #  endif
  77.  
  78. /* Page tables can have no gaps in HP-UX < 8.0, leave a gap for malloc. */
  79.  
  80. #  ifdef hp9000s300
  81. #    ifdef hpux8
  82. #      define ATTACH_POINT    0x60000000
  83. #    else /* not hpux8 */
  84. #      define MALLOC_SPACE    (2 << 20)    /* 2 Meg */
  85. #    endif /* hpux8 */
  86. #  endif /* hp9000s300 */
  87.  
  88. #endif /* _HPUX */
  89.  
  90. #ifdef HAVE_SYSV_SHARED_MEMORY
  91.  
  92. #define DRONE_VERSION_NUMBER        ((1 << 8) | 2)
  93.  
  94. #include <sys/time.h>
  95. #include <sys/ipc.h>
  96. #include <sys/shm.h>
  97. #include <sys/signal.h>
  98. #include <sys/types.h>
  99. #include <sys/wait.h>
  100.  
  101. #ifndef MALLOC_SPACE
  102. #  define MALLOC_SPACE    0
  103. #endif
  104.  
  105. #ifndef ATTACH_POINT
  106. #  define ATTACH_POINT    0
  107. #endif
  108.  
  109. #define DRONE_EXTRA_T
  110.  
  111. struct drone_extra_s
  112. {
  113.   pid_t my_pid;
  114.   pid_t my_ppid;
  115. };
  116.  
  117. typedef struct drone_extra_s drone_extra_t;
  118.  
  119. #define DRONE_PID    drone_extra.my_pid
  120. #define DRONE_PPID    drone_extra.my_ppid
  121.  
  122. #endif /* HAVE_SYSV_SHARED_MEMORY */
  123.  
  124. /* Shared definitions for all versions */
  125.  
  126. enum buffer_state
  127. {
  128.   buffer_idle,            /* 0 */
  129.   buffer_busy,            /* 1, used for scan or free */
  130.   buffer_ready,            /* 2, after being read */
  131.   buffer_queued,        /* 3, never written, use as if read */
  132.   buffer_being_read,        /* 4 */
  133.   buffer_read_error,        /* 5 */
  134.   buffer_being_written,        /* 6 */
  135.   buffer_write_error        /* 7 */
  136. };
  137.  
  138. struct buffer_info
  139. {
  140.   int index;
  141.   enum buffer_state state;
  142.   long position;
  143.   long size;
  144.   PTR bottom;
  145.   PTR top;
  146.   PTR end;
  147. };
  148.  
  149. enum drone_state
  150. {
  151.   drone_dead,            /* 0 */
  152.   drone_not_ready,        /* 1 */
  153.   drone_idle,            /* 2 */
  154.   drone_reading,        /* 3 */
  155.   drone_writing,        /* 4 */
  156.   drone_aborting        /* 5 */
  157. };
  158.  
  159. struct drone_info
  160. {
  161.   int index;
  162. #ifdef DRONE_EXTRA_T
  163.   drone_extra_t drone_extra;
  164. #endif
  165.   enum drone_state state;
  166.   int buffer_index;
  167.   long entry_offset;
  168. };
  169.  
  170. enum queue_entry_state
  171. {
  172.   entry_idle,            /* 0 */
  173.   entry_busy,            /* 1 */
  174.   entry_error            /* 2 */
  175. };
  176.  
  177. struct gc_queue_entry
  178. {
  179.   int index;
  180.   enum queue_entry_state state;
  181.   struct buffer_info * buffer;
  182.   int drone_index;
  183.   int error_code;
  184.   int retry_count;
  185. };
  186.  
  187. #endif /* _BCHDRN_H_INCLUDED */
  188.